

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>加次数</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 55px 0;">
      <div class="layui-form-item">
          <label class="layui-form-label">修改查看次数</label>
          <div class="layui-input-inline">
              <input type="hidden" name="id" value="${id}">
              <input type="text" name="showLimit" lay-verify="showLimit" placeholder="请输入" autocomplete="off" class="layui-input">
          </div>
      </div>

      <div style="width: 100%;height: 55px;background-color: white;border-top:1px solid #e6e6e6;position: fixed;bottom: 1px;">
          <div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">
              <button  class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">
                  确定
              </button>
              <button  class="layui-btn layui-btn-primary" id="close">
                  取消
              </button>
          </div>
      </div>

  </div>

  <script src="/layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
      base: '/layuiadmin/' //静态资源所在路径
  }).extend({
      index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
      let $ = layui.$
          ,form = layui.form;

      //自定义验证规则
      form.verify({
          showLimit: [/[0-9]\d*$/, '请填写整数']
      });

      $('#close').click(function(){
          let index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
      });

      //监听提交
      form.on('submit(add)', function(data){
          $.ajax({
              url:'updateShowLimit',
              type:'post',
              data:data.field,
              async:false, dataType: "json", traditional: true,
              success:function(data){
                  console.info(data.msg);
                  if (data.flag){
                      let index = parent.layer.getFrameIndex(window.name);
                      window.top.layer.msg(data.msg);
                      parent.layer.close(index);
                      parent.location.replace(parent.location.href);
                  }else {
                      window.top.layer.msg(data.msg);
                  }
              },error:function(){
                  window.top.layer.msg('请求失败');
              }
          });
          return false;
      });
      form.render();
  });
  </script>
</body>
</html>